import { ArrayStack } from "./01_数组实现栈结构";

function decimalToBinary(decimal: number): string {
  const arrayStack = new ArrayStack<number>();
  while (decimal > 0) {
    const result = decimal % 2;
    arrayStack.push(result);
    decimal = Math.floor(decimal / 2);
  }
  let binary = "";
  while (!arrayStack.isEmpty()) {
    binary = binary + arrayStack.pop();
  }
  console.log(binary);
  return binary;
}
decimalToBinary(35);
decimalToBinary(100);
